﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------
// this will include all needed files to be able to build a Request


include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the location to add
$longitude 	= "514.048";
$latitude 	= "3007.8325";

// symbol used 	to display the location
$symbolId	= "301";

// define the digitizer
$myDigitizer = "<![CDATA[http://" . $CONF['MAPTP_SYSTEM'] . "map24/webservices1.5?t=1170865168007&cgi=Map24MapletRemoteControl&mid=" . $CONF['MAP24_ID'] . "&sid=" . $CONF['SESSION_ID'];
$myDigitizer.= "&cmd0=ADD&id0=loc&x0=$515.048&y0=3007.8325&symbol_id0=302&cmd1=ENABLE&mobid1=loccmd2=MOV&mobid2=loc&clw_min2=3000]]>";

// zoomlevel
$mapViewClippingWidth = 2000;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new location/digitizer
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = "digitizer";
$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $longitude;
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $latitude;
$commands[$cmdIdx]->DeclareMap24Location->SymbolID = $symbolId;
$commands[$cmdIdx]->DeclareMap24Location->Customize = new MapObjectCustomSettings();
$commands[$cmdIdx]->DeclareMap24Location->Customize->Handler = "MAP24_LOCATION_DIGITIZER";
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties = array();
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0] = new Property();
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0]->Key = "SUBMIT_URL";
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0]->Value = $myDigitizer;

// this object will enable the new location on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "SHOW";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("digitizer");

// this object will center the map above the new location
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("digitizer");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;
?>